<%-- 
    Document   : formcategories
    Created on : 30-dic-2011, 2:04:50
    Author     : tpgalan
--%>

<%@page import="java.util.List"%>
<%@page import="com.sdd.plains.CategoryPlain"%>


<form action='./AddCategory' method='post'>
    <fieldset>
        <legend>Want to add a category?</legend>
        <p>Simply write a category name and specify (if wanted) the parent's category. Leve the father's category in "IS MAIN CATEGORY" if you want to create a parent category.</p>
    <p>Category name<input type='text' name='catname'/></p>
    <p>Category (father): 
        <select name="catfather" size="1">
            <option value="">IS MAIN CATEGORY</option>
            <%
                List<CategoryPlain> fathers = (List<CategoryPlain>) request.getSession().getAttribute("main_categories");
                for (CategoryPlain c : fathers) {%>
            <option value="<%=c.getCategoryId()%>"><%=c.getName()%></option>
            <%
                }
            %>
        </select>
    </p> <!--catfather-->
    <p><input type='submit' value='create'/></p>
    </fieldset>
</form>
        <hr>
        <div style="float: left;"><a href="./Admin?showall=true">Show all products</a></div>
        <div style="float: right;"><a href="./Admin?onlywithout=true">Show only products without categories</a></div>
        <br>
        <hr>
        <%
        String from= request.getParameter("from");
        String size= request.getParameter("size");
        int f = 0;
        int s = 10;
        if(from!=null && size!=null){
        f = Integer.valueOf(from);
        s = Integer.valueOf(size);
               }
        String cola = "";
        String show = request.getParameter("showall");
        String only = request.getParameter("onlywithout");
        if(show!=null){
            cola="&showall=true";
        }else if(only!=null){
            cola="&onlywithout=true";
        }
        
        %>
        <div style="float: left;"><a href="./Admin?from=<%=(f-10)<0?0:(f-10)%>&size=<%=s+cola%>">Less products<<</a></div>
        <div style="float: right;"><a href="./Admin?from=<%=(f+10)%>&size=<%=s+cola%>">>>More products</a></div>
        <br>